import {uuid} from '@/utils';

class Callback {
    constructor() {
        this.callback = {};
        this.windowInfo={};
        this.storageData={};
    }

    saveCallback(callback) {
        const functionId='function_id'+uuid();
        this.callback[functionId] = callback;
        return functionId;
    }

    trrigerCallback(callbackId,arges) {
        const callbackFunction=this.callback[callbackId]
        if(callbackFunction) {
            callbackFunction(...arges);
            delete this.callback[callbackId];
        }
    }
    
    getWindowInfo(opts) {
        /* console.log("getWindowInfo:opts:",opts)
        console.log("getWindowInfo:windowInfo:",this.windowInfo) */
        this.windowInfo = opts;
        return this.windowInfo;
    }
    getStorage(opts) {
        /* console.log("getWindowInfo:opts:",opts)
        console.log("getWindowInfo:windowInfo:",this.windowInfo) */
        this.storageData = opts;
        return this.windowInfo;
    }
}

export default new Callback();